package com.ruoyi.web.controller.shop.mapper;

import com.ruoyi.common.core.dao.BaseMapper;
import com.ruoyi.common.entity.DO.wechat.ShopAppletCommitDO;
import com.ruoyi.common.entity.VO.wechat.ShopAppletCommitSearchVO;
import com.ruoyi.common.entity.VO.wechat.ShopAppletCommitVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface IBackShopAppletCommitMapper extends BaseMapper<ShopAppletCommitDO> {

    List<ShopAppletCommitVO> searchList(ShopAppletCommitSearchVO shopAppletCommitSearchVO);

    @Delete("DELETE FROM shop_applet_commit WHERE applet_app_id=#{appId} and status in(0,1,3,4,10,11)")
    int deleteForCommitByAppId(String appId);

    @Update("UPDATE shop_applet_commit SET status=#{status} where id = #{id}")
    int updateStatusById(@Param("id") Long id, @Param("status") Integer status);

    @Update("UPDATE shop_applet_commit SET status=3 where applet_app_id = #{appId} and status=4")
    int backLatestByAppId(String appId);

    @Update("UPDATE shop_applet_commit SET status=4 where applet_app_id=#{appId} and status=3")
    int releaseByAppId(String appId);

    @Select("SELECT COUNT(1) FROM shop_applet_commit WHERE applet_app_id=#{appId} and status = 2")
    int countAuditingCommit(String appId);
}
